<?php
!defined('LZ_MODULE') && die('Access Denied');
$m = $_GET['m'];
include_once('model/guestbook.php');
$obj = new LZ_Guestbook;


if ($m == 'new')
{
	if (!$_SESSION['login_user'])
	{
		die("what do you want to do?");
	}
	$data = filter_array($_POST,'name!,email,htmlspecialchars:content!');
	if ($data)
	{
		$data['user_id'] = $_SESSION['login_user']['user_id'];
		$data['time'] = time();
		echo ($obj->add($data))?'success':'error';
	}
	else 
		echo lang('FILL_ALL');
	die;
}

$items = lz_page($obj,array('replied'=>true,'user_id'=>$_SESSION['login_user']['user_id']),(intval($config['guestbook_per_page']))?intval($config['guestbook_per_page']):10);

$view_data['items'] = $items;
$view_data['page_description'] = lang('GUESTBOOK');
$view_data['title'] = lang('GUESTBOOK');
$view_data['page_description'] = lang('GUESTBOOK');
$view_data['site_keywords'] = lang('GUESTBOOK');
include_once('controller/left.php');

?>